package show.marvelous.domain.chessgame.constans;

/**
 * The enum Piece enum.
 * @author Kris 2021/9/14
 */
public enum PieceEnum{
    /**
     *Red a piece enum.
     */
    RED_A(AirPlanColorEnum.RED, PieceCodeEnum.A),
    /**
     *Red b piece enum.
     */
    RED_B(AirPlanColorEnum.RED, PieceCodeEnum.B),
    /**
     *Red c piece enum.
     */
    RED_C(AirPlanColorEnum.RED, PieceCodeEnum.C),
    /**
     *Red d piece enum.
     */
    RED_D(AirPlanColorEnum.RED, PieceCodeEnum.D),
    /**
     *Yellow a piece enum.
     */
    YELLOW_A(AirPlanColorEnum.YELLOW, PieceCodeEnum.A),
    /**
     *Yellow b piece enum.
     */
    YELLOW_B(AirPlanColorEnum.YELLOW, PieceCodeEnum.B),
    /**
     *Yellow c piece enum.
     */
    YELLOW_C(AirPlanColorEnum.YELLOW, PieceCodeEnum.C),
    /**
     *Yellow d piece enum.
     */
    YELLOW_D(AirPlanColorEnum.YELLOW, PieceCodeEnum.D),
    /**
     *Blue a piece enum.
     */
    BLUE_A(AirPlanColorEnum.BLUE, PieceCodeEnum.A),
    /**
     *Blue b piece enum.
     */
    BLUE_B(AirPlanColorEnum.BLUE, PieceCodeEnum.B),
    /**
     *Blue c piece enum.
     */
    BLUE_C(AirPlanColorEnum.BLUE, PieceCodeEnum.C),
    /**
     *Blue d piece enum.
     */
    BLUE_D(AirPlanColorEnum.BLUE, PieceCodeEnum.D),
    /**
     *Green a piece enum.
     */
    GREEN_A(AirPlanColorEnum.GREEN, PieceCodeEnum.A),
    /**
     *Green b piece enum.
     */
    GREEN_B(AirPlanColorEnum.GREEN, PieceCodeEnum.B),
    /**
     *Green c piece enum.
     */
    GREEN_C(AirPlanColorEnum.GREEN, PieceCodeEnum.C),
    /**
     *Green d piece enum.
     */
    GREEN_D(AirPlanColorEnum.GREEN, PieceCodeEnum.D);
    private final AirPlanColorEnum color;
    private final PieceCodeEnum code;

    PieceEnum(AirPlanColorEnum color, PieceCodeEnum code){
        this.color = color;
        this.code = code;
    }

    /**
     * Of piece enum.
     *
     * @param color the color
     * @param code the code
     * @return the piece enum
     */
    public static PieceEnum of(AirPlanColorEnum color, PieceCodeEnum code){
        for(PieceEnum piece : PieceEnum.values()){
            if(piece.color == color && piece.code == code){
                return piece;
            }
        }
        throw new IllegalArgumentException("未定义的棋子");
    }

    /**
     * Get color air plan color enum.
     *
     * @return the air plan color enum
     */
    public AirPlanColorEnum getColor(){
        return color;
    }

    /**
     * Get code piece code enum.
     *
     * @return the piece code enum
     */
    public PieceCodeEnum getCode(){
        return code;
    }
}
